package com.tian.earth

import android.app.Application
import com.elvishew.xlog.LogLevel
import com.elvishew.xlog.XLog
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.scwang.smartrefresh.layout.footer.ClassicsFooter
import com.scwang.smartrefresh.layout.header.ClassicsHeader
import com.tian.earth.utils.PreferencesUtil

/**
 * @author tiansongtao, Email:769001510@qq.com
 * @date 19-5-24 下午10:22
 */

class EarthApp: Application() {

    companion object {
        init {
            SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout ->
                layout.setPrimaryColorsId(android.R.color.white, android.R.color.black)
                ClassicsHeader(context)
            }
            SmartRefreshLayout.setDefaultRefreshFooterCreator{ context, layout ->
                layout.setPrimaryColorsId(android.R.color.white, android.R.color.black)
                ClassicsFooter(context)
            }
        }
    }


    override fun onCreate() {
        super.onCreate()

        initLog()

        initPreference()

    }

    private fun initPreference() {
         PreferencesUtil.INSTANCE.init(this)
    }

    /**
     * 初始化日志控件
     */
    private fun initLog(){
        XLog.init(if (BuildConfig.DEBUG) LogLevel.ALL else LogLevel.NONE)
    }
}